// pages/delivery/delivery.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     this.setData({
       orderId: options.id
     })
  },

   expresses: function (e) {
    if (e.detail.value != '') {
      this.setData({
        _express: e.detail.value
      })
    }
  }
  , expressNum: function (e) {
    if (e.detail.value != '') {
      this.setData({
        express_num: e.detail.value
      })
    }
  },
  sendMsg:function(e){
    delivry(this);
  }
})


function delivry(that){
  wx.request({
    url: app.globalData.allUrl + "/orderr/dliver",
    data: {
      id: that.data.orderId,
      express: that.data._express,
      express_num: that.data.express_num,
    },
    header: { 'content-type': "application/json" },
    method: 'POST',
    success: function (res) {
      console.log(res.data);
      if(res.data==200){
        wx.showModal({
          title: '提示',
          content: '发货成功',
          success:function(res){
            if(res.confirm){
              wx.switchTab({
                url: '../../pages/my/my',
              })
            }else{
              wx.switchTab({
                url: '../../pages/my/my',
              })
            }
          }
        })
        
      } else if (res.data == 400){
        wx.showModal({
          title: '提示',
          content: '发货失败',
        })
      }
    }
  })
}